package com.gaussic.controller;

import com.alibaba.fastjson.JSON;
import com.gaussic.model.Result;
import com.gaussic.model.UserInfo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

/**
 * Created by zhangwenhan on 16/5/27.
 */

//@Controller
//public class MainController {
//    @RequestMapping(value = "/", method = RequestMethod.GET)
//    public String index() {
//        return "index";
//    }
//
//    @RequestMapping(value="/getUserInfo")
//    @ResponseBody
//    public Object getUserInfoJson(){
//        UserInfo userInfo = new UserInfo();
//        userInfo.setUserId("1001");
//        userInfo.setUserName("张三");
//
//        Result result = new Result();
//        result.setCode(200);
//        result.setMsg("");
//        result.setData(JSON.toJSON(userInfo));
//        return result;
//    }
//}

@RestController
public class MainController{
    @RequestMapping(value = "/", method = RequestMethod.GET)
    public Result index() {
        return new Result(200,"成功",null);
    }

    @RequestMapping("/getUserInfo")
    public Result getUserInfo(){
        return new Result(200,"成功",new UserInfo("1001","张三"));
    }
}
